<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <title>Login</title>
    <script src="resource/js/jquery-3.2.1.min.js"></script>
    <link href="resource/css/bootstrap/bootstrap.min.css" rel="stylesheet">
    <link href="resource/css/signin.css" rel="stylesheet">
  </head>

  <body>
    <div class="container">
      <div class="form-signin">
        <h2 class="form-signin-heading" style="text-align: center;">Admin System</h2>
        <label for="inputEmail" class="sr-only">UserName</label>
        <input type="text" id="inputName" class="form-control" placeholder="UserName" required autofocus>
        
        <label for="inputPassword" class="sr-only">Password</label>
        <input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
        
        <button id="btn-login" class="btn btn-lg btn-primary btn-block" type="submit">Login</button>
      </div>

    </div> <!-- /container -->
	<script type="text/javascript">
		$(function(){
			$("#btn-login").click(function(){
				var name = $("#inputName").val();
				var pwd = $("#inputPassword").val();
				$.post("/aeat/login",{"name":name,"pwd":pwd},function(data){
					var obj = JSON.parse(data);
					if(obj.code == 200){
						window.location.href = "/aeat/sec/admin-verify.jsp";
					}else{
						alert("Login failure. Reason="+obj.msg);
					}
				});
			});
		});
	</script>
  </body>
</html>